<template>
  <div class="card">
    <div class="left" @click="visible1 = true">读数（公斤）<span>0.00</span></div>
    <el-popover
      placement="top-start"
      title="称重筐设置"
      :visible="visible"
      :width="600"
      trigger="click"
    >
      <template #reference>
        <div class="right" @click="visible = !visible">
          <p>0.00</p>
          <p>称重框（0个）</p>
        </div>
      </template>
      <div class="list">
        <div class="itemBox" v-for="(item, index) in weightBox" :key="index">
          <div>
            选择框：
            <el-select v-model="item.box" placeholder="Select">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div>
            输入数量：<el-input-number v-model="item.num" :min="1" :max="10" />
            <el-icon @click="deleteFn(index)" class="icon"><Delete /></el-icon>
          </div>
        </div>
        <div class="btnBox" @click="addBox">
          <el-icon class="icon"><Plus /></el-icon>添选择称重筐
        </div>
      </div>
      <div class="bottomBtnBox">
        <el-button class="btn" @click="cancle">取消</el-button>
        <el-button class="btn" type="primary">确定</el-button>
      </div>
    </el-popover>
    <el-dialog v-model="visible1">
      <CkPage />
    </el-dialog>
  </div>
</template>

<script lang="ts" setup>
import CkPage from '../components/ckPage.vue'

import { ref } from 'vue'
const options = [
  {
    value: 'Option1',
    label: 'Option1'
  }
]
const visible = ref(false)
const visible1 = ref(false)
const weightBox = ref([
  {
    box: '',
    num: 0
  }
])
const addBox = () => {
  weightBox.value.push({
    box: '',
    num: 0
  })
}
const deleteFn = (index: number) => {
  weightBox.value.splice(index, 1)
}
const cancle = () => {
  visible.value = false
}
</script>

<style scoped lang="less">
.card {
  position: absolute;
  right: 0;
  bottom: 10px;
  background: #f9f9fc;
  border-radius: 8px 0px 0px 8px;
  border: 1px solid #ebebeb;
  display: flex;
  align-items: center;
  z-index: 999;
  .left {
    font-size: 24px;
    font-family:
      PingFangSC,
      PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 33px;
    padding: 34px 24px;
    span {
      font-weight: bold;
      color: #333333;
      line-height: 41px;
    }
  }
  .right {
    background: #ffffff;
    border-radius: 0px 8px 8px 0px;
    border: 2px solid #f3f4f9;
    padding: 20px 24px;
    padding-right: 60px;
    cursor: pointer;
    p {
      &:first-of-type {
        font-size: 32px;
        font-family: DINPro, DINPro;
        font-weight: 500;
        color: #333333;
        line-height: 41px;
      }
      &:last-of-type {
        font-size: 18px;
        font-family:
          PingFangSC,
          PingFang SC;
        font-weight: 400;
        color: #8083a3;
        line-height: 25px;
      }
    }
  }
}
.list {
  font-size: 16px;
  .itemBox {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    .icon {
      margin-left: 10px;
    }
  }
  .btnBox {
    width: 100%;
    height: 40px;
    border: 1px dashed #999999;
    line-height: 40px;
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;

    .icon {
      margin-right: 5px;
    }
    &:hover {
      transition: all 0.3s;
      border: 1px dashed #79bbff;
      color: #79bbff;
    }
  }
}
.bottomBtnBox {
  width: 100%;
  margin-top: 20px;
  display: flex;
  justify-content: center;
  .btn {
    width: 48%;
  }
}
</style>
